﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UsersByGPSGroups.aspx.cs" Inherits="GPSTrackingWebsiteManager.Manager.Pages.UsersByGPSGroups" %>

<%@ Register Src="~/Manager/UserControls/UsersByCompanyIDSearch.ascx" TagPrefix="uc1" TagName="UsersByCompanyIDSearch" %>

<!DOCTYPE html>

<link href="../../Css/GPSTrackingWebsite.css" rel="stylesheet" />
<link href="../../Css/messi.css" rel="stylesheet" />
<script src="../../Javascript/jquery-1.11.1.min.js"></script>
<script src="../../Javascript/messi.js"></script>
<script src="../../Javascript/Custom.js"></script>
<script src="../../Javascript/WindowMessageManager.js"></script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Asociar grupo dispositivos al usuario</title>
    <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
<script type="text/javascript">
    function resizeGrid() {
        var height = (window.innerHeight) - 25;

        var tableView = $find("<%=GPSGroupsGrid.ClientID %>");
        tableView.get_element().style.height = (height) / 2 + "px";

        var tableView = $find("<%=UsersSelectedGrid.ClientID %>");
        tableView.get_element().style.height = (height) / 2 + "px";

        document.getElementById('HiddenFieldHeight').value = (height);
        }

        //Windows Message Manager 
        var objWindowsMessageManager = new WindowsMessageManager();
    </script>
</telerik:RadScriptBlock>    
</head>
<body  onresize="resizeGrid()" style="overflow: hidden">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
          <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="GPSGroupsGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rmpGPSGroups" LoadingPanelID="RadAjaxLoadingPanel1"  />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError"  />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="UsersSelectedGrid">
                    <UpdatedControls>                        
                        <telerik:AjaxUpdatedControl ControlID="UsersSelectedGrid" LoadingPanelID="RadAjaxLoadingPanel1"  />
                        <telerik:AjaxUpdatedControl ControlID="HiddenFieldError"  />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <asp:HiddenField ID="HiddenFieldHeight" runat="server" Value="500" />
        <asp:HiddenField ID="HiddenFieldError" runat="server" />        
    
        <telerik:RadTabStrip ID="rtsGPSGroups" runat="server" SelectedIndex="0" MultiPageID="rmpGPSGroups" ></telerik:RadTabStrip>
        <telerik:RadMultiPage ID="rmpGPSGroups" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="rpvGPSGroups" runat="server">
        
        <div>
        <telerik:RadGrid ID="GPSGroupsGrid" runat="server" AllowSorting="true" AutoGenerateColumns="false" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnNeedDataSource="GPSGroupsGrid_NeedDataSource" OnSelectedIndexChanged="GPSGroupsGrid_SelectedIndexChanged" OnItemCommand="GPSGroupsGrid_ItemCommand" >
            <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                    <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Grupos de dispositivos:                              
                             <asp:LinkButton ID="lbClearFilters" runat="server" OnClick="lbClearFilters_Click"  Visible='<%# !GPSGroupsGrid.MasterTableView.IsItemInserted %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                            <asp:LinkButton ID="lbShowError" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>   
                        </div>                        
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo grupo" RefreshText="Actualizar"></CommandItemSettings>

                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

                <Columns>
                    <telerik:GridButtonColumn UniqueName="SelectColumn" CommandName="Select" Text="Seleccionar"  ButtonType="ImageButton" ImageUrl="../../Template/Icons/16px/PDA-icon.png" HeaderStyle-Width="25px" />
                    <telerik:GridBoundColumn DataField="GPSGroupId" FilterControlAltText="Filter Name column" HeaderText="Grupo ID" UniqueName="GPSGroupId"  ForceExtractValue="Always"  Display="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="GPSGroupIdSource.Name" FilterControlAltText="Filter Name column" HeaderText="Nombre" MaxLength="50" UniqueName="Name"
                        FilterControlWidth="200px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="230px" AutoPostBackOnFilter="true">                      
                    </telerik:GridBoundColumn>
                </Columns>

                <EditFormSettings>
                    <EditColumn InsertText="Agregar" UpdateText="Actualizar" CancelText="Cancelar" ButtonType="ImageButton"></EditColumn>
                </EditFormSettings>
            </MasterTableView>
             <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
    <br />    
        <telerik:RadGrid ID="UsersSelectedGrid" runat="server"  AllowSorting="true" AutoGenerateColumns="false" CellSpacing="0" GridLines="None" Height="100%" Width="100%" GroupingSettings-CaseSensitive="false" OnNeedDataSource="UsersSelectedGrid_NeedDataSource" OnDeleteCommand="UsersSelectedGrid_DeleteCommand">
         <MasterTableView EditMode="PopUp" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-CaptionFormatString="Modo Edición" CommandItemDisplay="TopAndBottom" NoMasterRecordsText="No hay registros" AllowFilteringByColumn="true" TableLayout="Auto">
                <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Nuevo Grupo" RefreshText="Actualizar"></CommandItemSettings>
                <CommandItemTemplate>
                        <div style="padding: 5px 5px;"> Usuarios Asociados: 
                             <asp:LinkButton ID="lbAdd" runat="server" OnClientClick="OpenUsersSearch()"><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/text-plus-icon.png"/>Asociar más Usuarios</asp:LinkButton>
                             <asp:LinkButton ID="lbClearFilters2" runat="server" OnClick="lbClearFilters2_Click"><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/mixx-icon.png"/>Limpiar Filtros</asp:LinkButton>                                                                               
                            <asp:LinkButton ID="lbShowError2" runat="server" OnClick="lbShowError_Click" Visible='<%# HiddenFieldError.Value == string.Empty ? false : true %>'><img style="padding-left:10px; padding-right:5px; vertical-align:middle" alt="" src="../../Template/Icons/16px/bug-icon.png"/>Error técnivo</asp:LinkButton>   
                        </div>                        
                    </CommandItemTemplate>

            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>

            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>

            <Columns>
                <telerik:GridButtonColumn  ConfirmText="¿Desea eliminar el registro?" Text="Eliminar" ConfirmDialogType="RadWindow" ConfirmDialogHeight="120" ConfirmDialogWidth="270" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" HeaderStyle-Width="25px"/>                                                     
                <telerik:GridBoundColumn DataField="Username" HeaderText="Username" UniqueName="Username"
                    FilterControlWidth="100px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="130px" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Nombre" UniqueName="Name"
                    FilterControlWidth="200px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="230px" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FirstName" HeaderText="Primer Apellido" UniqueName="FirstName"
                    FilterControlWidth="200px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="230px" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastName" HeaderText="Segundo Apellido" UniqueName="LastName"
                    FilterControlWidth="200px" CurrentFilterFunction="Contains" ShowFilterIcon="false" HeaderStyle-Width="230px" AutoPostBackOnFilter="true">
                </telerik:GridBoundColumn>
            </Columns>

            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            </EditFormSettings>            
        </MasterTableView>
  <ClientSettings EnableRowHoverStyle="true">
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"></Scrolling>
                     <Selecting AllowRowSelect="True"></Selecting><ClientEvents OnPopUpShowing="PopUpShowing" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
    </div>
    </telerik:RadPageView>
    </telerik:RadMultiPage>
    <uc1:UsersByCompanyIDSearch ID="UsersByCompanyIDSearch" runat="server" IsMultipleSelects="true" CalledBy="UsersByGPSGroups" IsClearGridAfterClose="false" OnOnAcceptEvent="uscUsersByCompanyIDSearch_OnAcceptEvent" OnOnCancelEvent="uscUsersByCompanyIDSearch_OnCancelEvent"/>
    </form>
</body>
</html>
